package cn.jetpiece.cloud.joss.api.object;

import cn.jetpiece.cloud.joss.api.object.model.params.CreateRegionParam;
import cn.jetpiece.cloud.joss.api.object.model.params.UpdateRegionParam;
import cn.jetpiece.cloud.joss.api.object.model.query.RegionQuery;
import cn.jetpiece.cloud.joss.api.object.model.result.RegionResult;
import cn.jetpiece.cloud.model.page.PageResult;
import cn.jetpiece.cloud.model.response.Result;
import cn.jetpiece.cloud.resource.annotation.annotation.ApiResource;
import cn.jetpiece.cloud.resource.annotation.annotation.ScanResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.validation.Valid;

/**
 * 域接口
 *
 * @author XuJZ
 * @since 2020-09-05 15:41:52
 */
@Api(tags = "域")
@ApiResource(name = "域")
public interface RegionApi {

    String API = "/oss/regions";

    /**
     * 新增域
     *
     * @param param 新增参数
     * @return 返回结果
     */
    @ApiOperation(value = "新增域")
    @ScanResource(name = "新增域", path = API, method = RequestMethod.POST)
    Result<String> add(@RequestBody @Valid CreateRegionParam param);

    /**
     * 修改域
     *
     * @param param 修改参数
     * @return 返回结果
     */
    @ApiOperation(value = "修改域")
    @ScanResource(name = "修改域", path = API, method = RequestMethod.PUT)
    Result<String> update(@RequestBody @Valid UpdateRegionParam param);

    /**
     * 删除域
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "删除域")
    @ScanResource(name = "删除域", path = API + "/{id}", method = RequestMethod.DELETE)
    Result<String> delete(@PathVariable(name = "id") String id);

    /**
     * 查询域信息
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "查询域信息")
    @ScanResource(name = "查询域信息", path = API + "/{id}", method = RequestMethod.GET)
    Result<RegionResult> get(@PathVariable(name = "id") String id);

    /**
     * 分页获取域
     *
     * @param query 查询条件
     * @return 返回结果
     */
    @ApiOperation(value = "分页获取域")
    @ScanResource(name = "分页获取域", path = API, method = RequestMethod.GET)
    Result<PageResult<RegionResult>> page(RegionQuery query);

}
